package com.hitqz.robot.arm.type;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 上电状态
 *
 * @author kehanjiang
 * @date 2023/09/15
 */
public enum PowerStateEnums {
    ON(0, "上电"),
    OFF(1, "下电"),
    ESTOP(2, "急停被按下"),
    GSTOP(3, "安全门打开"),
    UNKNOWN(-1, "未知(发生异常)"),
    ;

    private Integer code;

    private String desc;

    PowerStateEnums(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    private static final Map<Integer, PowerStateEnums> MAP = Stream.of(PowerStateEnums.values()).collect(Collectors.toMap(PowerStateEnums::getCode, v -> v));

    public static PowerStateEnums getByCode(Integer code) {
        return MAP.get(code);
    }
}
